<%--
  Created by IntelliJ IDEA.
  User: sitapro
  Date: 2017/6/2
  Time: 09:26
  To change this template use File | Settings | File Templates.
--%>
<script>

    var funct = null;
    var arg = null;
    var arg1 = null;
    var arg2 = null;

    //    errorCode : 错误代码
    //                小于0 警告
    //                等于0 成功
    //                大于0 失败
    //         data : 提示信息
    function showalert(errorCode, data) {
        $("#alert [name=mes]").html(data);

        var mesimg = $("#alert [name=mesimg]");
        if (errorCode < 0) {
            mesimg.attr("src", "../images/warning.png");
        } else if (errorCode == 0) {
            mesimg.attr("src", "../images/success.png");
        } else {
            mesimg.attr("src", "../images/failed.png");
        }
        $("#alert").modal('toggle');

    }

    //    data : 提示信息
    //    func : 确定后执行的方法
    function showconfirm(data, func) {
        $("#confirm [name=mes]").html(data);
        var mesimg = $("#confirm [name=mesimg]");
        mesimg.attr("src", "../images/warning.png");
        $("#confirm").modal('toggle');
        funct = func;
        $("#confirm #sure").one("click", gofunc);
    }

    //    data : 提示信息
    //    func : 确定后执行的方法
    //    args : 执行方法需要传入的参数
    function showconfirmwithargs(data, func, args) {
        $("#confirm [name=mes]").html(data);
        var mesimg = $("#confirm [name=mesimg]");
        mesimg.attr("src", "../images/warning.png");
        $("#confirm").modal('toggle');
        funct = func;
        arg = args;
        $("#confirm #sure").one("click", gofunc);
    }

    //    data : 提示信息
    //    func : 确定后执行的方法
    //    args1 : 执行方法需要传入的参数1
    //    args2 : 执行方法需要传入的参数2
    function showconfirmwithtwoargs(data, func, args1, args2) {
        $("#confirm [name=mes]").html(data);
        var mesimg = $("#confirm [name=mesimg]");
        mesimg.attr("src", "../images/warning.png");
        $("#confirm").modal('toggle');
        funct = func;
        arg1 = args1;
        arg2 = args2;
        $("#confirm #sure").one("click", gofunctwoargs);
    }

    //    确定执行方法
    function gofunc() {

        if (arg == null) {
            funct();
        } else {
            funct(arg);
        }
        funct = null;
        arg = null;
        $("#confirm [name=mes]").html("");
    }

    function gofunctwoargs() {
        if(funct !=null){
            funct(arg1, arg2);
        }
        funct = null;
        arg1 = null;
        arg2 = null;
        $("#confirm [name=mes]").html("");
    }


    //  清空alert消息
    function clearmes() {
        $("#alert [name=mes]").html("");
        $("#alert").modal('toggle');
    }



</script>
<style>
    .mesa {
        font-size: 15px;
        font-family: "Microsoft Yahei", "微软雅黑", "Pinghei";
        line-height: 40px;
        float: left;
        margin-left: 10px;
    }

    .mesimg {
        width: 30px;
        height: 30px;
        float: left;
        margin-top: 5px;
    }

    .container {
        padding: 10px;
        width: 538px;
    }

    .title {
        line-height: 40px;
        font-size: 16px;
        font-weight: bold;
        margin-left: 10px;
    }

    #alert, #confirm{
        z-index: 1051;
    }
</style>


<%--alert modal--%>
<div class="modal fade" id="alert">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <span><img src="" name="mesimg" class="mesimg"></span>
                <span class="title">提示信息</span>
                <%--<h4 class="modal-title">提示信息</h4>--%>
            </div>
            <div class="modal-body">
                <div class="container">
                    <div>
                        <%--<span><img src="" name="mesimg" class="mesimg"></span>--%>
                        <span>
                            <div name="mes" class="mesa"></div>
                        </span>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="clearmes()">确定
                </button>
            </div>
        </div>
    </div>
</div>


<%--confirm modal--%>
<div class="modal fade" id="confirm">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <span><img src="" name="mesimg" class="mesimg"></span>
                <span class="title">确认信息</span>
            </div>
            <div class="modal-body">
                <div class="container">
                    <%--<span><img src="" name="mesimg" class="mesimg"></span>--%>
                    <span><div name="mes" class="mesa"></div></span>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal" id="sure">确定
                </button>
                <button type="button" class="btn btn-primary" data-dismiss="modal">取消
                </button>
            </div>
        </div>
    </div>
</div>
